<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'testAjax.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<script type="text/javascript" src="./js/jquery-1.8.0.min.js"></script>
	<script type="text/javascript">
		$(function(){
			$("#login").click(function(){
				ajaxLogin();
			})
		})	
		function ajaxLogin(){
			$.ajax({
				type:"post",
				url:"deptApp/login",
				data:$("#loginForm").serialize(),
				success:function(msg){
					alert(msg.age);
				}
			})
		}
	</script>
  </head>
  
  <body>
  <form action="deptApp/login" method="post" id="loginForm">
  	<input name="name" value="wanglong" type="text">
  	<input name="password" value="wanglong" type="password">
  	<input type="submit" value="登录">
  	<input id="login"  type="button" value="ajax登录">
  </form>
  </body>
</html>
